<?php

namespace app\uniapp\controller;

use app\uniapp\middleware\CheckLogin;
use app\uniapp\service\UniAuthService;
use app\uniapp\service\UserPointsLogService;
use think\db\exception\DbException;

class UserPointsLogController extends UniController
{
    protected array $middleware = [
        CheckLogin::class,
    ];
    /**
     * @throws DbException
     */
    public function paginate(): \think\response\Json
    {
        $list = UserPointsLogService::instance()->setWhere([
            ['user_id', '=', UniAuthService::instance()->getLoginId()]
        ])->setOrder('create_time desc')->paginate(20);

        return jsonSuccess([
            'items' => $list->items(),
            'total' => $list->total(),
        ]);
    }
}
